"use strict";

$.Msg( "Hello, master.js!" );

GameUI.HideEnemyInfo = function(){}

function OnSelectUnit() {
	var unit = Players.GetQueryUnit(Players.GetLocalPlayer());

	if (Entities.IsEnemy(unit)) {
		GameUI.ShowEnemyInfo(unit);
	}
	else{
		GameUI.HideEnemyInfo();
	}

	if (unit > 0) {
		var unit_name = Entities.GetUnitName(unit);
		if (!GameUI.ShowPointsShop(unit, unit_name)) {
			var all_npc = CustomNetTables.GetTableValue("Common", "all_npc_task_entity_index");
			if (all_npc[unit_name] === unit) {
				GameUI.SwapFrame('npc_task',true);
				return;
			}
		}
		return;
	}

	if (GameUI.AllowShowCourierFrame()) {
		GameUI.SwapFrame('courier_frame',true);
		return;
	}
	
	GameUI.SwapFrame('hero_frame',true);
}

function OnPlaySound(data) {
	Game.EmitSound(data.sound);
}

var _ForceAutoSelectFate = true;
GameUI.ForceAutoSelectFate = function () {
	return _ForceAutoSelectFate;
}

;(function(){
	// VGUI
	// GameUI.SetRenderTopInsetOverride( 0 );
	// GameUI.SetRenderBottomInsetOverride( 0 );
	//GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_ACTION_PANEL, false );
	GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_ACTION_MINIMAP, false );
	//GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_PANEL, false );
	GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_SHOP, false );
	//GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_ITEMS, false );
	GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_QUICKBUY, false );
	GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_COURIER, false );
	GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_PROTECT, false );
	GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_INVENTORY_GOLD, false );
	GameUI.SetDefaultUIEnabled( DotaDefaultUIElement_t.DOTA_DEFAULT_UI_SHOP_SUGGESTEDITEMS, false );

	//GameEvents.Subscribe( "dota_player_update_selected_unit", OnSelectUnit );
	//GameEvents.Subscribe( "dota_player_update_query_unit", OnSelectUnit );
	//GameEvents.Subscribe( "play_sound", OnPlaySound );

	// GameUI.SetCameraPitchMin(25)
	// GameUI.SetCameraPitchMax(25)
	// GameUI.SetCameraLookAtPositionHeightOffset(200)

})()
